import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import {
  renderWithQiankun,
  qiankunWindow,
} from "vite-plugin-qiankun/dist/helper";

const root = createRoot(document.getElementById("root")!);
const render = () =>
  root.render(
    <StrictMode>
      <BrowserRouter basename="/app1/app2">
        <Routes>
          <Route path="/" element={<div>app2</div>} />
          <Route path="/App2children" element={<div> app2children</div>} />
        </Routes>
      </BrowserRouter>
    </StrictMode>
  );

renderWithQiankun({
  mount() {
    console.log("mount");
    render();
  },
  bootstrap() {
    console.log("bootstrap");
  },
  unmount() {
    console.log("unmount");
    root.unmount();
  },
  update() {
    console.log("update");
  },
});

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render();
}
